home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / univspl / viewunit.cpp < prev    next >
C/C++ Source or Header  |  1999-02-02  |  2KB  |  87 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include <math.h>
  6. #include "fftmain.h"
  7. #include "ViewUnit.h"
  8. //---------------------------------------------------------------------------
  9. #pragma resource "*.dfm"
  10. TViewForm *ViewForm;
  11. //---------------------------------------------------------------------------
  12. __fastcall TViewForm::TViewForm(TComponent* Owner)
  13.     : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TViewForm::SigPBPaint(TObject *Sender)
  18. {
  19. long i;
  20. long hh;
  21. long width;
  22.  
  23.    // clear old data
  24.    // Paint the Signal Window
  25.    hh=SigPB->Height/2;
  26.    width=SigPB->Width;
  27.    // Draw zero line
  28.    SigPB->Canvas->Pen->Color=clBlack;
  29.    SigPB->Canvas->Pen->Width=1;
  30.    SigPB->Canvas->MoveTo(0,hh);
  31.    SigPB->Canvas->LineTo(width,hh);
  32.  
  33.    // Draw the actual signal
  34.    SigPB->Canvas->Pen->Color=clBlue;
  35.    if (sig!=NULL)
  36.    {
  37.       SigPB->Canvas->MoveTo(0,hh-sig[0]);
  38.       for (i=1;i<num_samps;i++)
  39.         SigPB->Canvas->LineTo(i,hh-sig[i*2]);
  40.  
  41.    }
  42.  
  43.  
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TViewForm::FFTPBMouseMove(TObject *Sender, TShiftState Shift,
  47.     int X, int Y)
  48. {
  49.    BinLbl->Caption=IntToStr(X);
  50.    FreqLbl->Caption=FloatToStrF(X*bin_width,ffFixed,3,2);
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TViewForm::FFTPBPaint(TObject *Sender)
  54. {
  55. long i;
  56. long hh;
  57. long width;
  58.  
  59.    // Paint the fft window
  60.    hh=FFTPB->Height/2;
  61.    width=FFTPB->Width;
  62.    // Draw zero line
  63.    FFTPB->Canvas->Pen->Color=clBlack;
  64.    FFTPB->Canvas->Pen->Width=1;
  65.    FFTPB->Canvas->MoveTo(0,hh);
  66.    FFTPB->Canvas->LineTo(width,hh);
  67.  
  68.    // Draw the actual signal
  69.    FFTPB->Canvas->Pen->Color=clBlue;
  70.    if (fftreal!=NULL)
  71.    {
  72.       FFTPB->Canvas->MoveTo(0,hh-100.0*fabs(fftreal[0]));
  73.       for (i=1;i<fsize/2;i++)
  74.         FFTPB->Canvas->LineTo(i,hh-100.0*fabs(fftreal[i]));
  75.  
  76.    }
  77.  
  78.  
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TViewForm::FormPaint(TObject *Sender)
  82. {
  83.     SigPB->Invalidate();
  84.     FFTPB->Invalidate();
  85. }
  86. //---------------------------------------------------------------------------
  87.